package phaseI;
public class DFAScanner {
	private DFATable table;
	
	public DFAScanner(DFATable table) {
		this.table = table;
	}
	
	public boolean matches(String arg) {
		String state = "1";
		
		for (int i = 0; i < arg.length(); i++) {
			String nextState = table.getStateFromTransition(state, arg.substring(i, i+1));
			if (nextState == null) return false;
			state = nextState;
		}
		return table.hasEndState(state);
	}
}
